<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *订单管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['status']=$this->jiqilog_status;
$tabs=array(
	array('op'=>'list','title'=>'全部记录'),
); 
if($_RQ['op']=='list'){
	$return['params']=array();
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(isset($_RQ['type']) && $_RQ['type']!=100){
		$params['type']=intval($_RQ['type']);
		$return['params']['type']=intval($_RQ['type']);
	}
	if(isset($_RQ['mid'])){
		$params['mid']=intval($_RQ['mid']);
		$return['params']['mid']=intval($_RQ['mid']);
	}
	if(isset($_RQ['teamid'])){
		$params['teamid']=intval($_RQ['teamid']);
		$return['params']['teamid']=intval($_RQ['teamid']);
	}
	if($_RQ['times']){
		$params['times']=$_RQ['times'];
		$return['params']['times']=$_RQ['times'];
	}
	if($_RQ['dayid']){
		$params['dayid']=$_RQ['dayid'];
		$return['params']['dayid']=$_RQ['dayid'];
	}
	$pindex = max(1, intval($_RQ['page']));
	if($_RQ['psize']){
		$_SESSION['psize']=$_RQ['psize'];
	}
	$psize = $_SESSION['psize']?:10;
	$list=pdo_getslice('jy_newping_log',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as $k=>&$item){
			$item['member']=cfc('core')->member_show($item['mid']);
			$pinggoods=pdo_get('jy_newping_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['pingid']));
			$item['goods']=pdo_get('jy_weishop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$pinggoods['goodsid']),array('title','image'));
			if($item['type']==0 && $item['canzhong']==1){
				$item['msg'] .='(未满次)';
			}
			/*if($item['type']==4 && $item['status']==1 && $item['createtime']<=1622079145){
				if($item['gift_type']>=1){
					if($item['gift_type']==2){
						$this->model('member')->recharge($item['mid'],$item['other_credit_fee'],7,'返现保证金');
					}else{
						model('core/member')->member_credit($item['mid'],'credit'.$item['other_type'],$item['other_credit_fee'],true,'jy_newping','拼单参与额外大奖');
					}
				}
			}*/
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>$tabs,
		'list'=>array('data'=>'list','total'=>$total,'psize'=>$psize,'edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'member','title'=>'会员信息_Member','type'=>'member'),
			array('name'=>'goods.title','title'=>'拼团商品','type'=>'string'),
			array('name'=>'goods.image','title'=>'拼团商品图片','type'=>'image'),
			array('name'=>'type','title'=>'类型','type'=>'radio','options'=>'types'),
			array('name'=>'msg','title'=>'备注','type'=>'string'),
			array('name'=>'dayid','title'=>'日期','type'=>'string'),
			array('name'=>'timeid','title'=>'时间段','type'=>'string'),
			array('name'=>'createtime','title'=>'预约时间','type'=>'time'),
		)),
		'search'=>array(
			array('type'=>'radio','width'=>15,'name'=>'type','options'=>'types','title'=>'类型'),
			array('name'=>'teamid','title'=>'团ID','type'=>'string','width'=>15),
			array('name'=>'dayid','title'=>'日期','type'=>'string','width'=>15),
			array('name'=>'times','title'=>'时间段','type'=>'string','width'=>15),
			array('type'=>'choose','width'=>15,'action'=>'core/member.get_member/','name'=>'mid','title'=>'选择会员'),
		),
	);
	$return['types']=$this->log_type;
	$return['htmls']=$htmls;	
	exi($return);
}
